print("============ 欢迎使用计算机 =================")
print("*            20242118符馨琰         *")
print("*            2025.3.26              *")
print("*            pilot twice              *")
print("==========================================")

import math

def Csum(num1, num2):
    return num1 + num2

def Csub(num1, num2):
    return num1 - num2

def Cmulti(num1, num2):
    return num1 * num2

def CDiv(num1, num2):
    if num2 == 0:
        print("除数不能为0")
        return 0
    return num1 / num2

def Mod(num1, num2):
    return num1 % num2

def pusin(num1, num2):
    return math.sin(num1) * math.sin(num2) + math.cos(num1) * math.cos(num2)

def logab(a, b):
    return math.log(a, b)

num1 = eval(input("请输入num1:"))
num2 = eval(input("请输入num2:"))

flag = True  # 将 flag 变量的定义移到 while 循环外部
while flag:
    if input("请问：需要复数(1)还是整数(2)运算？\n") == "1":
        num1 = complex(input("请输入一个数："))
        num2 = complex(input("请输入另一个数："))
    else:
        num1 = int(input("请输入一个数："))
        num2 = int(input("请输入另一个数："))
    choice = input("请输入运算符（+ - * / % log sin ）：")
    if choice == "+":
        print("num1 ", choice, " num2 = ", Csum(num1, num2))
    elif choice == "-":
        print("num1 ", choice, " num2 = ", Csub(num1, num2))
    elif choice == "*":
        print("num1 ", choice, " num2 = ", Cmulti(num1, num2))
    elif choice == "/":
        print("num1 ", choice, " num2 = ", CDiv(num1, num2))
    elif choice == "%":
        print("num1 ", choice, " num2 = ", Mod(num1, num2))
    elif choice == "sin":
        print("num1 ", choice, " num2 = ", pusin(num1, num2))
    elif choice == "log":
        print("log以", num2, "为底", num1, "的对数 = ", logab(num1, num2))

    conti = input("是否继续？Y/N\n")
    if conti == "Y" or conti == "y":
        flag = True
    else:
        flag = False